from typing import Optional, List

from bct.tools.common.bct4.base_dto import JsonDTO

from enum import Enum
from typing import Optional, List

from bct.tools.common.bct4.base_dto import JsonDTO


class AttrDataType(Enum):
    TEXT = 'TEXT'
    PERCENTAGE = 'PERCENTAGE'


class CustomizeAttributeDTO(JsonDTO):
    category: Optional[str]
    code: Optional[str]
    # PERCENTAGE TEXT
    data_type: AttrDataType
    name: Optional[str]
    scopes: List[str]
    required: bool

    def to_dict(self):
        return {
            'category': self.category,
            'code': self.code,
            'dataType': self.data_type.value,
            'name': self.name,
            'scopes': self.scopes,
            'required': self.required
        }

    def __init__(self, param={}):
        self.category = param.get('category', None)
        self.code = param.get('code', None)
        self.data_type = param.get('dataType', AttrDataType.TEXT)
        self.name = param.get('name', None)
        self.scopes = param.get('scopes', [])
        self.required = param.get('required', False)
